﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace CsharpTpl.window
{
    public class FrmMainMenuHandler
    {
        private FrmMain _owner;
        private FrmSelectSkin _FormSelectSkin;
        private FrmRoleManage _FrmRoleManage;
        private FrmCZYManage _FrmCZYManage;
        private FrmDMLB _FrmDMLB;
        private FrmDMBMX _FrmDMBMX;
        private FrmReportManage _FrmReportManage;
        public FrmMainMenuHandler(FrmMain owner)
        {
            this._owner = owner;
            
        }
        public void HandleMenuClick(object sender, EventArgs e)
        {
            string CZM="";
            if (sender.GetType().Name.Equals("MenuStrip"))
            {
                MenuStrip menu = (MenuStrip)sender;
                CZM = menu.Name;
            }
            else if (sender.GetType().Name.Equals("ToolStripMenuItem"))
            {
                ToolStripMenuItem menu = (ToolStripMenuItem)sender;
                CZM = menu.Name;
            }
            switch (CZM)
            {
                //系统退出
                case "TC":
                    Application.Exit();
                    break;
                case "PFXZ":
                    if (_FormSelectSkin==null || _FormSelectSkin.IsDisposed)
                    {
                        _FormSelectSkin = new FrmSelectSkin();
                    }
                    _FormSelectSkin.ShowDialog(_owner);
                    break;
                case "JSGL":
                    if (_FrmRoleManage==null|| _FrmRoleManage.IsDisposed)
                    {
                        _FrmRoleManage = new FrmRoleManage();
                    }
                    _FrmRoleManage.ShowDialog(_owner);
                    break;
                case "CZYGL":
                    if (_FrmCZYManage==null||_FrmCZYManage.IsDisposed)
                    {
                        _FrmCZYManage = new FrmCZYManage();
                    }
                    _FrmCZYManage.ShowDialog(_owner);
                    break;
                case "DMBLB":
                    if (_FrmDMLB == null || _FrmDMLB.IsDisposed)
                    {
                        _FrmDMLB = new FrmDMLB();
                    }
                    _FrmDMLB.ShowDialog(_owner);
                    break;
                case "DMBMX":
                    if (_FrmDMBMX == null || _FrmDMBMX.IsDisposed)
                    {
                        _FrmDMBMX = new FrmDMBMX();
                    }
                    _FrmDMBMX.ShowDialog(_owner);
                    break;
                case "BBWH":
                    if (_FrmReportManage==null||_FrmReportManage.IsDisposed)
                    {
                        _FrmReportManage = new FrmReportManage();
                    }
                    _FrmReportManage.ShowDialog(_owner);
                    break;
                case "QHYH":
                    _owner.Dispose();
                    new FrmLogin().Show();
                    break;
                default:
                    break;
            }
        }
    }
}
